# coding: utf-8
from PySide6.QtCore import Qt
from PySide6.QtGui import QPainter
from PySide6.QtWidgets import QWidget
from qfluentwidgets import Pivot as P
from qfluentwidgets.common.color import autoFallbackThemeColor


class Pivot(P):
    def paintEvent(self, e):
        QWidget.paintEvent(self, e)

        if not self.currentItem():
            return

        painter = QPainter(self)
        painter.setRenderHints(QPainter.RenderHint.Antialiasing)
        painter.setPen(Qt.PenStyle.NoPen)
        painter.setBrush(autoFallbackThemeColor(self.lightIndicatorColor, self.darkIndicatorColor))
        painter.drawRoundedRect(0, self.height() - 3, self.currentItem().width(), 3, 1.5, 1.5)
        painter.end()
